package cs;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class FileGet {
    public static void main(String[] args)throws Exception {
        System.out.println("input a filename:");
        String fileName=new Scanner(System.in).next();
        Socket s=new Socket("47.93.151.29",8888);
        InputStream in=s.getInputStream();
        OutputStream out=s.getOutputStream();
        out.write((fileName+"\r\n").getBytes());
        out.flush();
        byte[]b=new byte[2048];
        int len=0;
        FileOutputStream fout=new FileOutputStream("d:/"+fileName);
        while((len=in.read(b))!=-1){
            fout.write(b,0,len);
        }
        fout.close();
        s.close();
    }
}
